package com.mai.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mai.dao.ProductMapper;
import com.mai.entity.Product;

@Service
public class ProductService {
	
	@Autowired
	private ProductMapper pm;
	
	public List<Product> selectAllProduct(){
		return pm.selectAllProduct();
	}
	
	public List<Product> Mohu(String product_category){
		return pm.Mohu(product_category);
	}
	
	public Product selectProductById(int id) {
		return pm.selectProductById(id);
	}
	
	/**
	 * 添加
	 */
	public boolean addProduct(Product product) {
		
		if(pm.addProduct(product)>0) {
			return true;
		}else {
			return false;
		}
	}
	
	/**
	 * 修改
	 */
	public boolean updateProduct(Product product) {
		if(pm.updateProduct(product)>0) {
			return true;
		}else {
			return false;
		}
	}
	
	public boolean deleteProductById(int product_id) {
		if(pm.deleteProductById(product_id)>0) {
			return true;
		}else {
			return false;
		}
	}
	
}
